package com.bt.lms.ui.action.school_education.graduat;

import com.bt.lms.ui.page.sys.style.BtnStyle;
import javafx.collections.ObservableList;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;

/**
 * 编辑就业信息时间
 */
public class EditEmploymentAction implements EventHandler {

    private Integer baseWidth;

    private VBox totalVBox;

    private VBox vBox;
    public EditEmploymentAction(VBox totalVBox, Integer baseWidth, VBox vBox) {
        this.baseWidth = baseWidth;
        this.totalVBox = totalVBox;
        this.vBox = vBox;
    }

    @Override
    public void handle(Event event) {
        HBox hBox = new HBox();
        hBox.setPrefWidth(baseWidth);
        Insets insets1 = new Insets(0,50,0,10);
        hBox.setPadding(insets1);
        hBox.setSpacing(20);
        hBox.setAlignment(Pos.CENTER_RIGHT);
        Button saveBtn = new Button("保存");
        Button cancelBtn = new Button("取消");
        hBox.getChildren().add(saveBtn);
        hBox.getChildren().add(cancelBtn);
        //按钮样式
        BtnStyle.saveBtn(saveBtn);
        BtnStyle.cancelBtn(cancelBtn);
        saveBtn.setCursor(Cursor.HAND);
        cancelBtn.setCursor(Cursor.HAND);
        ObservableList<Node> children = this.totalVBox.getChildren();
        children.set(2,hBox);

        /**
         * 取消按钮事件
         */
        cancelBtn.setOnAction(event1 -> {
            HBox hBox1 = new HBox();
            hBox1.setPrefWidth(baseWidth);
            hBox1.setPadding(new Insets(0,50,0,10));
            hBox1.setAlignment(Pos.CENTER_RIGHT);
            Button editBtn = new Button("💻编辑");
            hBox1.getChildren().add(editBtn);
            //按钮样式
            BtnStyle.saveBtn(editBtn);
            editBtn.setCursor(Cursor.HAND);
            //给编辑按钮加事件
            EditEmploymentAction editEmploymentAction = new EditEmploymentAction(totalVBox,baseWidth,vBox);
            editBtn.setOnAction(editEmploymentAction);

            children.set(2,hBox1);
            children.set(3,vBox);


        });

        //基本信息的主盒子
        VBox vBox = new VBox();
        vBox.setPrefWidth(baseWidth);
        vBox.setSpacing(10);

        HBox one = new HBox();
        one.setPrefWidth(baseWidth);
        one.setSpacing(10);
        Label firmLab = new Label("公司名");
        firmLab.setPrefWidth(baseWidth/8);
        TextField firmTF = new TextField();
        firmTF.setId("firmTF");
        firmTF.setPrefWidth(baseWidth/4);
        Label firmSiteLab = new Label("公司地址");
        firmSiteLab.setPrefWidth(baseWidth/8);
        HBox siteHBox = new HBox();
        siteHBox.setPrefWidth(baseWidth/3);
        siteHBox.setSpacing(10);
        ComboBox provinceLab = new ComboBox<>();//省
        provinceLab.setId("provinceLab");
        provinceLab.setPrefWidth(50);
        ComboBox cityLab = new ComboBox<>();//市
        cityLab.setId("cityLab");
        cityLab.setPrefWidth(50);
        ComboBox countyLab = new ComboBox<>();//县
        countyLab.setId("countyLab");
        countyLab.setPrefWidth(70);
        TextField detailedLab = new TextField();//详细地址
        detailedLab.setId("detailedLab");
        siteHBox.getChildren().addAll(provinceLab,cityLab,countyLab,detailedLab);
        one.getChildren().addAll(firmLab,firmTF,firmSiteLab,siteHBox);


        HBox two = new HBox();
        two.setPrefWidth(baseWidth);
        two.setSpacing(10);
        Label signedLab = new Label("协议签订日期");
        signedLab.setPrefWidth(baseWidth/8);
        DatePicker signedDP = new DatePicker();
        signedDP.setId("signedDP");
        signedDP.setPrefWidth(baseWidth/4);
        Label registerLab = new Label("报到日期");
        registerLab.setPrefWidth(baseWidth/8);
        DatePicker registerDP = new DatePicker();
        registerDP.setId("registerDP");
        registerDP.setPrefWidth(baseWidth/4);
        two.getChildren().addAll(signedLab,signedDP,registerLab,registerDP);

        HBox three = new HBox();
        three.setPrefWidth(baseWidth);
        three.setSpacing(10);
        Label firmTypeLab = new Label("企业类型");
        firmTypeLab.setPrefWidth(baseWidth/8);
        ComboBox firmTypeCB = new ComboBox<>();
        firmTypeCB.setId("firmTypeCB");
        firmTypeCB.getItems().addAll("有限责任有限公司","股份有限公司","个人独资企业",
                "合伙企业","全民所有制企业","集体所有制企业","农民专用合作社");
        firmTypeCB.setPrefWidth(baseWidth/4);
        three.getChildren().addAll(firmTypeLab,firmTypeCB);


        HBox four = new HBox();
        four.setPrefWidth(baseWidth/4);
        four.setSpacing(10);
        Label firmDescribeLab = new Label("公司描述");
        firmDescribeLab.setPrefWidth(baseWidth/8);
        TextArea firmDescribeTA = new TextArea();
        firmDescribeTA.setId("firmDescribeTA");
        firmDescribeTA.setMaxWidth(baseWidth-100);
        firmDescribeTA.setMaxHeight(100);
        four.getChildren().addAll(firmDescribeLab,firmDescribeTA);


        vBox.getChildren().addAll(one,two,three,four);
        children.set(3,vBox);






    }
}
